<script setup>
import axios from 'axios'
import { onMounted, ref } from 'vue'
const pagination = ref([])
const currentPage = ref(1)
const pageSize = ref(6)

onMounted(() => {
  handleCurrentChange()
})
const handleCurrentChange = () => {
  axios.get('api/answercontroller/answers/' + currentPage.value + '/' + pageSize.value).then(res => {
    pagination.value = res.data
    console.log(pagination.value)
  })
}

// const tableRowClassName = ({ row, rowIndex }) => {
//   if (rowIndex % 2 === 0) {
//     return 'warning-row'
//   } else {
//     return 'success-row'
//   }
// }
</script>

<template>
<div class="exam">
    <el-table :data="pagination.records" :border="true" >
      <el-table-column fixed="left" prop="subject" label="试卷名称" width="180"></el-table-column>
      <el-table-column prop="question" label="题目信息" width="490"></el-table-column>
      <el-table-column prop="section" label="所属章节" width="200"></el-table-column>
      <el-table-column prop="type" label="题目类型" width="200"></el-table-column>
      <el-table-column prop="score" label="试题分数" width="150"></el-table-column>
      <el-table-column prop="level" label="难度等级" width="133"></el-table-column>
    </el-table>
    <div class="box"></div>
     <el-pagination
      v-model:currentPage="currentPage"
      v-model:page-size="pageSize"
      :page-sizes="[1,2,3]"
      :small="small"
      :disabled="disabled"
      :background="background"
      layout="total, sizes, prev, pager, next, jumper"
      :total="80"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<style lang="less" scoped>
.box{
  padding-top: 5px;
}
.exam {
  padding: 0px 40px;
  .page {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edit {
    margin-left: 20px;
  }
  .el-table tr {
    background-color: #DD5862 !important;
  }
}
  .el-table .warning-row {
    background: #000 !important;

  }

  .el-table .success-row {
    background: #DD5862;
  }
</style>
